//
//  ShakeProd.m
//  JiaoX
//
//  Created by yinqy on 15/4/22.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "ShakeProd.h"

@implementation ShakeProd

-(void)setShake:(Shake *)shake{
    _shake = shake;
    [self setCornerRadius:5 borderWidth:0 borderColor:nil];
    [self.enterBtn setBackgroundImage:[UIImage imageWithColor:JXThemeColor] forState:UIControlStateNormal];
    [self.enterBtn setCornerRadius:2.5 borderWidth:0 borderColor:nil];
    [self.prodImage sd_setImageWithURL:[NSURL URLWithString:shake.shakeImg]];
    [self.prodName setText:shake.shakeName];
    
    NSMutableDictionary *rangs = [NSMutableDictionary dictionary];
    UIColor *color2 = JXThemeColor;
    NSInteger index = 0;
    NSMutableString *content = [NSMutableString string];
    //设置名称的rang

    [content appendFormat:@"￥%@",shake.dPrice];
    [rangs setObject:color2 forKey:NSStringFromRange(NSMakeRange(index, content.length+1))];
    index = content.length;
    [content appendFormat:@" ￥%@",shake.money];
    [rangs setObject:[UIFont systemFontOfSize:12] forKey:NSStringFromRange(NSMakeRange(index, content.length-index))];
    [self.prodPrice setAttributedText:[Utils getAttribtString:content attrRangs:rangs]];
    
    [self.enterBtn addTarget:self action:@selector(enterBtnClick:) forControlEvents:UIControlEventTouchUpInside];
}

-(void)enterBtnClick:(UIButton *)btn{
    if (self.operation) {
        self.operation();
    }
}

@end
